<?php

namespace app\index\controller;

use think\Controller;
use think\Request;
use think\Validate;

class User extends Controller
{
    public function register()
    {
        return view('user/register');
    }

    public function doregister(Request $request)
    {
//        var_dump($_POST);
//        var_dump($request);
        $p = $request->post();
        $rules = ['name'  => 'require|max:11', 'pass'=> 'number|between:1,120'];

//        $msg = [
//            'name.require' => '账号必须',
//            'name.max'     => '账号最多不能超过25个字符',
//            'name.number'  => '账号必须是数字',
//            'pass.require' => '密码必须是数字',
//            'pass.between' => '密码不能超过20个字符',
//            'repass'  => '密码和重新输入密码要一致'
//        ];
        $p = [
            'name'=>'15251707052',
            'pass'=>'1234'
        ];
        $validate = new Validate($rules);
        $result   = $validate->check($p);
        var_dump($result);
//        $result = Db::name('hc_user')
//            ->data($data)
//            ->insert();
    }
}
